<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>数组练习求和</title>
	</head>
	<body>
		<h4>输出描述:</h4>
		<p>计算给定数组 arr 中所有元素的总和</p>
		<span>sum([ 1, 2, 3, 4 ])</span>
		<script>
			var arr = [1,2,3,4];
			var sum = 0;
			 arr.forEach(function (i){
				sum += i;
			})
			console.log(sum);
		</script>
	</body>
</html>
